<template>
  <div>
    <input type="file" :id="id" @change="fileChange()" hidden :multiple="mode">
  </div>
</template>

<script lang="ts" setup>
import {v4 as uuidv4} from 'uuid';
import {propTypes} from "@/utils/propTypes";
import mitt from "mitt";

const props = defineProps({
  mode: propTypes.bool.def(false),
})
// mitt实现服务监听
const Mit = mitt()
const id = uuidv4()
const fileChange = () => {
  const node = document.getElementById(id);
  const file = node['files'];
  Mit.emit('uploadSuccess', file)
}
const upload = () => {
  const node = document.getElementById(id);
  node.click();
}
</script>

<style scoped>

</style>
